package com.guldan.thrall.util;

import com.guldan.jaina.dto.gauthority.GAuthorityDTO;
import com.guldan.jaina.dto.users.UserCacheDTO;
import com.guldan.jaina.dto.users.UsersDTO;

import java.util.List;

/**
 * Created by Silas.
 * Date: 2016/12/8
 * Time: 1:36
 */
public class UserUtils {

    private static ThreadLocal<UserCacheDTO> threadLocal = new ThreadLocal<UserCacheDTO>();

    public static void setUser(UserCacheDTO dto) {
        threadLocal.set(dto);
    }

    //获取用户登录信息
    public static UsersDTO getUser() {

        return threadLocal.get() != null ? threadLocal.get().getUser() : null;
    }

    //获取用户授权的菜单
    public static List<GAuthorityDTO> getMenu() {
        return threadLocal.get() != null ? threadLocal.get().getMenu() : null;

    }

}
